﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ListSportTeam.ascx.cs" Inherits="SMS.Admin.Modules.ListSportTeam" %>
<%@ Register Assembly="digit.Core" Namespace="digit.Core" TagPrefix="sms" %>
<%@ Import Namespace="SMS.Helper" %>
<div id="box">
    <h3>DANH SÁCH MÃ - NHÓM MÃ</h3>
    
    <fieldset id="warning">
        <legend>Thông báo</legend>
        
        <div align="center"><asp:Label ID="lblError" runat="server" /></div>
    </fieldset><br />

    <div align="center"><asp:Button ID="lnkAdd" runat="server" OnClick="lnkAdd_Click" Text="Thêm mới" />&nbsp;&nbsp;&nbsp;<asp:Button ID="lnkDelete" runat="server" OnClick="lnkDelete_Click" Text="Xóa" /></div>

    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td colspan="2" align="center">
	            <asp:GridView ID="grvTeam" runat="server" Width="98%" AutoGenerateColumns="False"
	                OnSorting="grvTeam_Sorting" OnPageIndexChanging="grvTeam_PageIndexChanging">
                    <PagerSettings PageButtonCount="10" />
                    <FooterStyle BackColor="#1EB5DD" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#1EB5DD" ForeColor="White" />
                    <RowStyle Height="30px" ForeColor="#333333" HorizontalAlign="Center" />
                    <HeaderStyle BackColor="#eeecdf" Font-Bold="True" ForeColor="#a4363a" />
                    <AlternatingRowStyle BackColor="#f7f6f0" Height="30px" ForeColor="#284775" />
                    <Columns>
                    <asp:TemplateField>
                        <HeaderStyle HorizontalAlign="Center" Width="20px" />
                        <HeaderTemplate>
                            <input type="checkbox" id="cbxHeader" runat="server" value="" onclick="MarkAll()" style="border:0px" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <input type="checkbox" id="cbxItem" runat="server" value='<%# Eval("TeamID") %>' onclick="MarkOne()" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Stt">
                        <ItemTemplate><%# Container.DataItemIndex + 1 %></ItemTemplate>
                    </asp:TemplateField>
                    <asp:HyperLinkField DataTextField="TeamName" ItemStyle-Wrap="true" SortExpression="TeamID" ItemStyle-HorizontalAlign="center" HeaderText="Tên đội" DataNavigateUrlFields="TeamID" DataNavigateUrlFormatString="~/Default.aspx?module=DetailSportTeam&teamId={0}" />  
                    <asp:TemplateField HeaderText="Mã đội" HeaderStyle-Wrap="false">
                        <ItemTemplate><%# Eval("TeamCode") %></ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Phân loại" HeaderStyle-Wrap="false">
                        <ItemTemplate><%# FormHelper.FormatCodeType(Util.ToInteger(Eval("Type").ToString()))%></ItemTemplate>
                    </asp:TemplateField>            
                </Columns>
	            </asp:GridView>
            </td>
        </tr>
     </table><br />
        
    <div align="center"><asp:Button ID="lnkAddBottom" runat="server" OnClick="lnkAdd_Click" Text="Thêm mới" />&nbsp;&nbsp;&nbsp;<asp:Button ID="lnkDeleteBottom" runat="server" OnClick="lnkDelete_Click" Text="Xóa" /></div><br />

</div>
<script language="javascript" type="text/javascript">
    var grid = document.getElementById('<%= this.grvTeam.ClientID %>');
	
    function MarkAll()
    {
	    var isChecked = document.getElementById('<%= (this.grvTeam.HeaderRow == null) ? "" : this.grvTeam.HeaderRow.Cells[0].Controls[1].ClientID %>').checked;
	    for (i = 1; i < grid.rows.length; i++)
	    {
		    grid.rows[i].cells[0].children[0].checked = isChecked;
	    }
    }
    function MarkOne()
    {
	    var cbx = document.getElementById('<%= (this.grvTeam.HeaderRow == null) ? "" : this.grvTeam.HeaderRow.Cells[0].Controls[1].ClientID %>');
	    cbx.checked = false;
		
	    for (i = 1; i < grid.rows.length; i++)
	    {
		    if (!grid.rows[i].cells[0].children[0].checked) return;
	    }
	    cbx.checked = true;
    }
	
    function CheckSelect()
    {
	    for (i = 1; i < grid.rows.length; i++)
	    {
		    if (grid.rows[i].cells[0].children[0].checked) return true;
	    }
	    alert('Không có bản ghi nào được đánh dấu');
	    return false;
    }
</script>